package com.summer.framework.common.entity;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @auther: 杨杰
 * @date: 2018/12/14 17:36
 * @description:
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
/*@TableName("users")*/
public class Users extends BaseEntity implements Serializable {

    private String username;

    private String password;

    private String mobile;

    private boolean enabled;

    private boolean accountNonExpired;

    private boolean credentialsNonExpired;

    private boolean accountNonLocked;

    public Users(String username, String password) {
        this.username = username;
        this.password = password;
    }

    public static final class UserBuilder {
        private String username;
        private String password;
        private String mobile;
        private boolean enabled;
        private boolean accountNonExpired;
        private boolean credentialsNonExpired;
        private boolean accountNonLocked;

        private UserBuilder() {
        }

        public static UserBuilder anUser() {
            return new UserBuilder();
        }

        public UserBuilder withUserName(String username) {
            this.username = username;
            return this;
        }

        public UserBuilder withPassword(String password) {
            this.password = password;
            return this;
        }

        public UserBuilder withMobile(String mobile) {
            this.mobile = mobile;
            return this;
        }

        public UserBuilder withEnabled(boolean enabled) {
            this.enabled = enabled;
            return this;
        }

        public UserBuilder withAccountNonExpired(boolean accountNonExpired) {
            this.accountNonExpired = accountNonExpired;
            return this;
        }

        public UserBuilder withCredentialsNonExpired(boolean credentialsNonExpired) {
            this.credentialsNonExpired = credentialsNonExpired;
            return this;
        }

        public UserBuilder withAccountNonLocked(boolean accountNonLocked) {
            this.accountNonLocked = accountNonLocked;
            return this;
        }

        public Users build() {
            Users user = new Users();
            user.setUsername(username);
            user.setPassword(password);
            user.setMobile(mobile);
            user.setEnabled(enabled);
            user.setAccountNonExpired(accountNonExpired);
            user.setCredentialsNonExpired(credentialsNonExpired);
            user.setAccountNonLocked(accountNonLocked);
            return user;
        }
    }
}
